$().ready(function() {
    loadInfo(126);//公司介绍
    loadCae(142);//CAE项目工程履历
    loadListInfo(128,"test1_l");//CrachFEM MAT材料失效数据库
    loadListInfo(129,"test2_l");//壁障有限元模型
    loadListInfo(130,"test3_l");//CAE分析相关工具软件开发与集成

    //解决方案简介
    $("#closeMethod").find(".layui-nav-item").on("click",function(index,item){
        $(".dataList").each(function(index,item){
            $(this).css("display","none");
        });
        $("#"+$(this).attr("data-bind-id")).css("display","");
        $("#closeMethod").find(".layui-nav-item").each(function(index,item){
            $(this).css("background-color","#ffffff");
        });
    });
    $(".dataList").eq(0).css("display","");

    //新闻
    loadNewList(133);

});

//加载新闻列表
function loadNewList(menuId) {
    $.ajax({
        cache: true,
        type: "GET",
        url: "/blog/menu/"+menuId,
        data: $('#signupForm').serialize(),// 你的formid
        async: false,
        error: function (request) {
            alert("Connection error");
        },
        success: function (data) {
            $("#newList").html("");
            var strHtml = "";
            $.each(data,function(index,item){
                if(index==0){
                    $("#newImg").attr("src",item.webThumb);
                    $("#newImghref").attr("href","/blog/views?contentId="+item.id);
                }else{
                    var a_click = "/blog/views?contentId="+item.id;
                    strHtml+="<div><span class='layui-badge-dot' style='margin-right:10px;'></span><a href='"+a_click+"'>"+item.webTitle+"</a></div>";
                }
            });
            $("#newList").html(strHtml);
        }
    });
}


function loadListInfo(menuId,idValue){
    $.ajax({
        cache: true,
        type: "GET",
        url: "/blog/menu/"+menuId,
        data: $('#signupForm').serialize(),// 你的formid
        async: false,
        error: function (request) {
            alert("Connection error");
        },
        success: function (data) {
            console.log("data"+data);
            $("#"+idValue).html("");
            var strHtml = "";
            $.each(data,function(index,item){
                var a_click = "/blog/views?contentId="+item.id;
                strHtml+="<div class='layui-row layui-col-space25'>";
                strHtml+="<div class='layui-col-sm6 layui-col-md4'>";
                strHtml+="<img src="+item.webThumb+" style='width:362px;height:280px;'>";
                strHtml+="</div>";
                strHtml+="<div class='layui-col-sm6 layui-col-md8' style='padding-left:35px;'>";
                strHtml+="<div class='content' style='height:250px;'>";
                strHtml+="<div style='line-height:25px;overflow:hidden;height:180px;text-indent:2em;'>"+item.webResume+"</div>";
                strHtml+="<a href='"+a_click+"'>";
                strHtml+="<button type='button' class='layui-btn layui-btn-danger' style='float:left;margin-top:60px;'>详细介绍></button>";
                strHtml+="</a>";
                strHtml+="</div>";
                strHtml+="</div>";
                strHtml+="</div>";
            });
            $("#"+idValue).html(strHtml);
        }
    });
}

function loadInfo(menuId) {
    $.ajax({
        cache: true,
        type: "GET",
        url: "/blog/menu/"+menuId,
        data: $('#signupForm').serialize(),// 你的formid
        async: false,
        error: function (request) {
            alert("Connection error");
        },
        success: function (data) {
            console.log("index"+data.length);
            $.each(data,function(index,item){
                $("#companyImgSrc").attr("src",item.webThumb);
                $("#companyShow").html(item.webResume);
                $("#companyhref").attr("href","/blog/views?contentId="+item.id);
            });
        }
    });
};

function loadCae(menuId){
    $.ajax({
        cache: true,
        type: "GET",
        url: "/blog/menu/"+menuId,
        data: $('#signupForm').serialize(),// 你的formid
        async: false,
        error: function (request) {
            alert("Connection error");
        },
        success: function (data) {
            $("#productList").html("");
            var strHtml = "";
            $.each(data,function(index,item){
                var a_click = "/blog/views?contentId="+item.id;
                if(index==0){
                    strHtml+="<div class='layui-col-sm6 layui-col-md3'>";
                    strHtml+="<div class='content' style='height:220px;'>";
                    strHtml+="<div style='line-height:25px;overflow:hidden;height:175px;text-indent:2em;'>";
                    strHtml+="<p>"+item.webResume+"</p>";
                    strHtml+="</div>";
                    strHtml+="<a href='"+a_click+"'>查看产品 ></a>";
                    strHtml+="</div>";
                    strHtml+="</div>";
                }else{
                    strHtml+="<div class='layui-col-sm6 layui-col-md3'>";
                    strHtml+="<div class='content' style='padding:0px;'>";
                    strHtml+="<div><img src="+item.webThumb+" style='width:100%;height:200px;'></div>";
                    strHtml+="<a href='"+a_click+"'>查看产品 ></a>";
                    strHtml+="</div>";
                    strHtml+="</div>";
                }
            });
            $("#productList").html(strHtml);
        }
    });
}